<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>
<body>
    <script src="js/common.js"></script>
    <input type="button" id="btn" value="关灯"><br>
    <!-- <script>
        var btn = my$("btn");
        btn.onclick = function(){
            if(btn.value==="关灯"){
                document.body.style.backgroundColor="black";
                this.value="开灯";
            }
            else{
                document.body.style.backgroundColor="";
                this.value="关灯";
            }
        }
    </script>    -->
    <script>
        var btn = my$("btn");
        var isOpen = true;
        btn.onclick = function(){
            if(isOpen){
                document.body.style.backgroundColor="black";
                this.value="开灯";
                isOpen = false;
            }
            else{
                document.body.style.backgroundColor="";
                this.value="关灯";
                isOpen = true;
            }
        }
    </script>
</body>
</html>